package pages

import (
	"github.com/templui/templui/internal/ui/layouts"
	"github.com/templui/templui/internal/ui/modules"
	"github.com/templui/templui/internal/ui/showcase"
)

templ Rating() {
	@layouts.DocsLayout(
		"Rating",
		"Interactive rating component for capturing user feedback and displaying scores.",
		[]modules.TableOfContentsItem{
			{
				ID:   "installation",
				Text: "Installation",
			},
			{
				Text: "Examples",
				ID:   "examples",
				Children: []modules.TableOfContentsItem{
					{
						Text: "With Label",
						ID:   "with-label",
					},
					{
						Text: "Styles",
						ID:   "styles",
					},
					{
						Text: "Precision (Read-Only)",
						ID:   "precision-read-only",
					},
					{
						Text: "Max Values",
						ID:   "max-values",
					},
					{
						Text: "Form",
						ID:   "form",
					},
				},
			},
			{
				ID:   "api-reference",
				Text: "API Reference",
				Children: []modules.TableOfContentsItem{
					{
						ID:   "rating",
						Text: "Rating",
					},
					{
						ID:   "group",
						Text: "Group",
					},
					{
						ID:   "item",
						Text: "Item",
					},
				},
			},
		},
	) {
		@modules.PageWrapper(modules.PageWrapperProps{
			Name:        "Rating",
			Description: templ.Raw("Interactive rating component for capturing user feedback and displaying scores."),
			Tailwind:    true,
			VanillaJS:   true,
			Breadcrumbs: modules.Breadcrumbs{
				Items: []modules.BreadcrumbItem{
					{
						Text: "Docs",
						Path: "/docs",
					},
					{
						Text: "Components",
						Path: "/docs/components",
					},
					{
						Text: "Rating",
					},
				},
			},
		}) {
			@modules.ExampleWrapper(modules.ExampleWrapperProps{
				ShowcaseFile:    showcase.RatingDefault(),
				PreviewCodeFile: "rating_default.templ",
			})
			@modules.ContainerWrapper(modules.ContainerWrapperProps{
				Title: "Installation",
				ID:    "installation",
			}) {
				@modules.ComponentUsage(modules.ComponentUsageProps{
					ComponentName: "rating",
					JSFiles:       []string{"rating"},
				})
			}
			@modules.ContainerWrapper(modules.ContainerWrapperProps{
				Title: "Examples",
				ID:    "examples",
			}) {
				@modules.ExampleWrapper(modules.ExampleWrapperProps{
					SectionName:     "With Label",
					ShowcaseFile:    showcase.RatingWithLabel(),
					PreviewCodeFile: "rating_with_label.templ",
					ID:              "with-label",
				})
				@modules.ExampleWrapper(modules.ExampleWrapperProps{
					SectionName:     "Styles",
					ShowcaseFile:    showcase.RatingStyles(),
					PreviewCodeFile: "rating_styles.templ",
					ID:              "styles",
				})
				@modules.ExampleWrapper(modules.ExampleWrapperProps{
					SectionName:     "Precision (Read-Only)",
					ShowcaseFile:    showcase.RatingPrecision(),
					PreviewCodeFile: "rating_precision.templ",
					ID:              "precision-read-only",
				})
				@modules.ExampleWrapper(modules.ExampleWrapperProps{
					SectionName:     "Max Values",
					ShowcaseFile:    showcase.RatingMaxValues(),
					PreviewCodeFile: "rating_max_values.templ",
					ID:              "max-values",
				})
				@modules.ExampleWrapper(modules.ExampleWrapperProps{
					SectionName:     "Form",
					ShowcaseFile:    showcase.RatingForm(),
					PreviewCodeFile: "rating_form.templ",
					ID:              "form",
				})
			}
			@modules.ContainerWrapper(modules.ContainerWrapperProps{
				Title: "API Reference",
				ID:    "api-reference",
			}) {
				@modules.APILegend()
				<div id="rating" class="mb-8">
					@modules.APITable(modules.APITableProps{
						Title:       "Rating",
						Description: "Main rating component container.",
						Items: []modules.APITableItem{
							{
								Name:        "ID",
								Type:        "string",
								Default:     "\"\"",
								Description: "Unique identifier for the rating component",
							},
							{
								Name:        "Class",
								Type:        "string",
								Default:     "\"\"",
								Description: "Additional CSS classes to apply to the rating container",
							},
							{
								Name:        "Attributes",
								Type:        "templ.Attributes",
								Default:     "nil",
								Description: "Additional HTML attributes to apply to the rating container",
							},
							{
								Name:        "Value",
								Type:        "float64",
								Default:     "0",
								Description: "Current rating value",
							},
							{
								Name:        "ReadOnly",
								Type:        "bool",
								Default:     "false",
								Description: "Whether the rating is read-only",
							},
							{
								Name:        "Precision",
								Type:        "float64",
								Default:     "1.0",
								Description: "Precision for rating values (e.g., 0.5 for half-star ratings)",
							},
							{
								Name:        "Name",
								Type:        "string",
								Default:     "\"\"",
								Description: "Name attribute for the hidden input field",
							},
							{
								Name:        "OnlyInteger",
								Type:        "bool",
								Default:     "false",
								Description: "Whether to only allow integer rating values",
							},
						},
					})
				</div>
				<div id="group" class="mb-8">
					@modules.APITable(modules.APITableProps{
						Title:       "Rating.Group",
						Description: "Container for grouping rating items.",
						Items: []modules.APITableItem{
							{
								Name:        "ID",
								Type:        "string",
								Default:     "\"\"",
								Description: "Unique identifier for the group element",
							},
							{
								Name:        "Class",
								Type:        "string",
								Default:     "\"\"",
								Description: "Additional CSS classes to apply to the group",
							},
							{
								Name:        "Attributes",
								Type:        "templ.Attributes",
								Default:     "nil",
								Description: "Additional HTML attributes to apply to the group",
							},
						},
					})
				</div>
				<div id="item">
					@modules.APITable(modules.APITableProps{
						Title:       "Rating.Item",
						Description: "Individual rating item (star, heart, emoji).",
						Items: []modules.APITableItem{
							{
								Name:        "ID",
								Type:        "string",
								Default:     "\"\"",
								Description: "Unique identifier for the item element",
							},
							{
								Name:        "Class",
								Type:        "string",
								Default:     "\"\"",
								Description: "Additional CSS classes to apply to the item",
							},
							{
								Name:        "Attributes",
								Type:        "templ.Attributes",
								Default:     "nil",
								Description: "Additional HTML attributes to apply to the item",
							},
							{
								Name:        "Value",
								Type:        "int",
								Default:     "0",
								Description: "Numeric value for this rating item",
							},
							{
								Name:        "Style",
								Type:        "Style",
								Default:     "star",
								Description: "Visual style for the rating item (star, heart, emoji)",
							},
						},
					})
				</div>
			}
		}
	}
}
